package com.tcs.test.netty.client.channelinit;

import com.tcs.model.datastandardization.RequestStanBean;
import com.tcs.model.datastandardization.ResponseStanBean;
import com.tcs.model.ipdata.IpDataBean;
import com.tcs.test.netty.client.channel.ObjectInChannel;
import com.tcs.test.netty.client.coder.decoder.MyDecoder;
import com.tcs.test.netty.client.coder.encoder.MyEncoder;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;

public class MyChannelInitializer extends ChannelInitializer {

    @Override
    protected void initChannel(Channel ch) throws Exception {
//        ch.pipeline().addLast("lineBasedFrameDecoder",new LineBasedFrameDecoder(1024));
//        ch.pipeline().addLast(new StringEncoder(Charset.forName("UTF-8")));
//        ch.pipeline().addLast(new StringDecoder(Charset.forName("GBK")));
        ch.pipeline().addLast(new MyEncoder(ResponseStanBean.class));
        ch.pipeline().addLast(new MyDecoder(RequestStanBean.class));
//        ch.pipeline().addLast(new IdleStateHandler(0,5,0, TimeUnit.SECONDS));
//        ch.pipeline().addLast("oneChannel",new ClientInChannel());
//        ch.pipeline().addLast("twoChannel",new TwoInChannel());
        ch.pipeline().addLast("twoChannel",new ObjectInChannel());
    }
}
